################ -*- mode: Makefile; -*- #############################
##
## Copyright (C) 2007-2008,  Karlsruhe University
##
## File path:     Mk/Makeconf.x86
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## 1. Redistributions of source code must retain the above copyright
##    notice, this list of conditions and the following disclaimer.
## 2. Redistributions in binary form must reproduce the above copyright
##    notice, this list of conditions and the following disclaimer in the
##    documentation and/or other materials provided with the distribution.
##
## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
## ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
######################################################################

# Pull in Makeconfs from new x86 directories.
# This can go away once x86 becomes a first class architecture.
SRCSRC+= src/arch/x86/$(SUBARCH) src/glue/$(API)-x86/$(SUBARCH) 

ifeq "$(CONFIG_DEBUG)" "y"
SRCSRC+= kdb/arch/x86/$(SUBARCH) kdb/glue/$(API)-x86/$(SUBARCH) 
endif
UNDEFS	 += $(SUBARCH)
DEFINES	 += __SUBARCH__=$(SUBARCH)

CFLAGS_x86_x32	+= -O2 -mpreferred-stack-boundary=2 
CFLAGS_x86_x64  += -O2 -m64 -mcmodel=kernel -mno-red-zone 
CFLAGS_x86	+= $(CFLAGS_x86_$(SUBARCH))

LDFLAGS_x86_x64	+= -melf_x86_64 -n -z max-page-size=4096
LDFLAGS_x86	+= $(LDFLAGS_x86_$(SUBARCH))

ASMFLAGS_x86_x64 += -m64 
ASMFLAGS_x86	 += $(ASMFLAGS_x86_$(SUBARCH))

VFLAGS_x86_x64	 = -m elf_x86_64
VFLAGS		 += $(VFLAGS_x86_$(SUBARCH))

CFLAGS_i486	+=-march=i486
CFLAGS_i586	+=-march=i586
ifeq "$(SUBARCH)" "x32"
CFLAGS_i686	+=-march=i686
endif

ifeq "$(CC_VERSION)" "4"
 ifeq "$(CONFIG_X86_SMALL_SPACES)" "y"
 CFLAGS_x86 += -Wno-invalid-offsetof 
 endif
 CFLAGS_p4  +=	-march=nocona
 CFLAGS_k8  +=	-march=k8
else
 ifeq "$(SUBARCH)" "x32"
 CFLAGS_p4  +=	-march=pentium4
 CFLAGS_k8  +=  -march=athlon
 endif
endif

LIBS_x86_x32  +=   -lgcc
LIBS_x86      +=   $(LIBS_x86_$(SUBARCH))
